package school.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import school.domain.OrderDoctor;
import school.domain.OrderVol;
import school.extra.base.BaseController;
import school.extra.layui.ResponseList;
import school.mapper.OrderDoctorMapper;
import school.mapper.OrderVolMapper;
import zhibi.frame.domain.Page;
import zhibi.frame.mybatis.example.Example;
import zhibi.frame.mybatis.example.ExampleType;

@RequestMapping("order")
@Controller
public class OrderController extends BaseController {
    @Autowired
    private OrderDoctorMapper orderDoctorMapper;
    @Autowired
    private OrderVolMapper orderVolMapper;

    @RequestMapping("docList")
    public String docList() {
        return "list-doc";
    }

    @ResponseBody
    @RequestMapping("docListData")
    public ResponseList docListData(OrderDoctor orderDoctor, Page page, Model model) {
        Example example = Example.getInstance()
                .addParam("username", orderDoctor.getUsername(), ExampleType.Operation.LIKE);
        return new ResponseList(orderDoctorMapper.selectByExample(example));
    }


    @RequestMapping("volList")
    public String volList() {
        return "list-vol";
    }

    @ResponseBody
    @RequestMapping("volListData")
    public ResponseList volListData(OrderVol orderVol, Page page, Model model) {
        Example example = Example.getInstance()
                .addParam("username", orderVol.getUsername(), ExampleType.Operation.LIKE);
        return new ResponseList(orderVolMapper.selectByExample(example));
    }

}
